﻿using SUNRPA.CONTROLS.IMPL.domain.attrubutes;
using SUNRPA.CONTROLS.IMPL.domain.flowRunningVar;
using SUNRPA.CONTROLS.IMPL.util;
using System.Collections.Concurrent;
/// <summary>
/// Excel有Office和Wps目前只支持Office后期加入Wps支持。
/// </summary>
namespace SUNRPA.CONTROLS.IMPL.domain.flowItemParam {
    [Serializable]
    [VarFieldName("TargetRowNum", "TargetColumnNum")]
    public class GetCellPostionNParam:BaseParam {
        private string searchObject = "{excelObject}";
        //搜索范围0区域，1行，2列，3已使用区域
        private int searchRange = 3;
        private string row;
        private string column;
        private string endRow;
        private string endColumn;
        private string searchValue;
        private string sheetName;
        private string targetRowNum = "targetRowNum";
        private string targetColumnNum = "targetColumnNum";
        public int SearchRange {
            get => searchRange; 
            set { 
                searchRange = value;
                NotifyPropertyChanged("SearchRange");
            }  
        }
        public string TargetRowNum {
            get => targetRowNum; 
            set { 
                targetRowNum = value;
                NotifyPropertyChanged("TargetRowNum");
            }  
        }
        public string TargetColumnNum {
            get => targetColumnNum; 
            set { 
                targetColumnNum = value;
                NotifyPropertyChanged("TargetColumnNum");
            }  
        }
        public string SearchValue {
            get => searchValue; 
            set { 
                searchValue = value;
                NotifyPropertyChanged("SearchValue");
            }  
        }

        public string SearchObject {
            get => searchObject; 
            set { 
                searchObject = value;
                NotifyPropertyChanged("SearchObject");
            }  
        }
        public string EndRow {
            get => endRow; 
            set { 
                endRow = value;
                NotifyPropertyChanged("EndRow");
            }  
        }

        public string EndColumn {
            get => endColumn; 
            set { 
                endColumn = value;
                NotifyPropertyChanged("EndColumn");
            }  
        }
        public string Row {
            get => row; 
            set { 
                row = value;
                NotifyPropertyChanged("Row");
            }  
        }
        public string Column {
            get => column; 
            set { 
                column = value;
                NotifyPropertyChanged("Columns");
            }
}
        public string SheetName {
            get => sheetName; 
            set { 
                sheetName = value;
                NotifyPropertyChanged("SheetName");
            }  
        }
        public string GetTranslateRange() {
            switch(this.searchRange) {
                case 0:
                    return "区域";
                case 2:
                    return "列";
                case 1:
                    return "行";
                case 3:
                    return "已使用区域";
                default : return "已使用区域";
            }
        }

        public override void SetLatestVarName(ConcurrentDictionary<string, ConcurrentDictionary<string, RPAVariableDefineWrapper>> globleData) {
            this.targetRowNum = this.GetLatestName(this.targetRowNum, globleData);
            this.targetColumnNum = this.GetLatestName(this.targetColumnNum, globleData);
        }
    }
}
